/**
 * Created with IntelliJ IDEA.
 * Description：
 * User：user
 * DATE:2021-10-24
 * Time:15:06
 */
public class TestDemo {
    public static ListNode mergeTwoLists(ListNode headA, ListNode headB) {
        ListNode newNode = new ListNode(-1);
        ListNode tmp = newNode;
        while(headA != null && headB != null){
            if (headA.val < headB.val) {
                tmp.next = headA;
                headA = headA.next;
                tmp = tmp.next;
            }else{
                tmp.next = headB;
                headB = headB.next;
                tmp = tmp.next;
            }
        }
        if(headA != null){
            tmp.next = headA;
        }
        if(headB != null){
            tmp.next = headB;
        }
        return newNode.next;
    }
    public static void main2(String[] args) {
        MyLinkedList myLinkedList1 = new MyLinkedList();
        myLinkedList1.addLast(11);
        myLinkedList1.addLast(17);
        myLinkedList1.addLast(19);
        MyLinkedList myLinkedList2 = new MyLinkedList();
        myLinkedList2.addLast(2);
        myLinkedList2.addLast(5);
        myLinkedList2.addLast(25);
        ListNode node = mergeTwoLists(myLinkedList1.head,myLinkedList2.head);
        myLinkedList1.display2(node);

    }
    public static void main(String[] args) {
        MyLinkedList myLinkedList = new MyLinkedList();
        myLinkedList.createLinkedList();
        myLinkedList.display();
        System.out.println(myLinkedList.getSize());
        myLinkedList.addFirst(1);
        myLinkedList.addFirst(2);
        myLinkedList.display();
        myLinkedList.addLast(3);
        myLinkedList.addLast(4);
        myLinkedList.display();
        myLinkedList.addIndex(1,99);
        //myLinkedList.addIndex(-1,99);
        myLinkedList.display();
        //System.out.println(myLinkedList.contains(99));
        myLinkedList.addIndex(1,99);
        myLinkedList.display();
        //myLinkedList.remove(99);
        //myLinkedList.removeAllKey(99);
       // myLinkedList.display();
        //myLinkedList.display2(myLinkedList.reverseList());
        //System.out.println(myLinkedList.middleNode().val);
        //System.out.println(myLinkedList.FindKthToTail(5).val);
        //myLinkedList.display2(myLinkedList.partition(4));
        myLinkedList.reverseBetween(2,5);
        myLinkedList.display();
    }
}
